
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <title>forkJoin · 学习 RxJS 操作符</title>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.1.1">
        
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-advanced-emoji/emoji-website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-prism/prism.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
        <link rel="stylesheet" href="../../styles/website.css">
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="merge.html" />
    
    
    <link rel="prev" href="concatall.html" />
    

    <style>
    @media only screen and (max-width: 640px) {
        .book-header .hidden-mobile {
            display: none;
        }
    }
    </style>
    <script>
        window["gitbook-plugin-github-buttons"] = {"buttons":[{"user":"RxJS-CN","repo":"learn-rxjs-operators","type":"star","size":"small","count":true},{"user":"RxJS-CN","repo":"learn-rxjs-operators","type":"fork","size":"small","count":true}]};
    </script>

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" >
            
                <a target="_blank" href="https://github.com/RxJS-CN/learn-rxjs-operators">
            
                    
                    学习 RxJS 操作符
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../../about/README.md">
            
                <span>
            
                    
                    关于中文版
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">学习 RxJS</li>
        
        
    
        <li class="chapter " data-level="2.1" data-path="../../">
            
                <a href="../../">
            
                    
                    前言
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="../">
            
                <a href="../">
            
                    
                    操作符
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.2.1" data-path="./">
            
                <a href="./">
            
                    
                    组合
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.2.1.1" data-path="combineall.html">
            
                <a href="combineall.html">
            
                    
                    combineAll
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.1.2" data-path="combinelatest.html">
            
                <a href="combinelatest.html">
            
                    
                    combineLatest
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.1.3" data-path="concat.html">
            
                <a href="concat.html">
            
                    
                    concat
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.1.4" data-path="concatall.html">
            
                <a href="concatall.html">
            
                    
                    concatAll
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="2.2.1.5" data-path="forkjoin.html">
            
                <a href="forkjoin.html">
            
                    
                    forkJoin
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.1.6" data-path="merge.html">
            
                <a href="merge.html">
            
                    
                    merge
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.1.7" data-path="mergeall.html">
            
                <a href="mergeall.html">
            
                    
                    mergeAll
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.1.8" data-path="pairwise.html">
            
                <a href="pairwise.html">
            
                    
                    pairwise
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.1.9" data-path="race.html">
            
                <a href="race.html">
            
                    
                    race
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.1.10" data-path="startwith.html">
            
                <a href="startwith.html">
            
                    
                    startWith
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.1.11" data-path="withlatestfrom.html">
            
                <a href="withlatestfrom.html">
            
                    
                    withLatestFrom
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.1.12" data-path="zip.html">
            
                <a href="zip.html">
            
                    
                    zip
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.2.2" data-path="../conditional/">
            
                <a href="../conditional/">
            
                    
                    条件
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.2.2.1" data-path="../conditional/defaultifempty.html">
            
                <a href="../conditional/defaultifempty.html">
            
                    
                    defaultIfEmpty
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.2.2" data-path="../conditional/every.html">
            
                <a href="../conditional/every.html">
            
                    
                    every
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.2.3" data-path="../creation/">
            
                <a href="../creation/">
            
                    
                    创建
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.2.3.1" data-path="../creation/create.html">
            
                <a href="../creation/create.html">
            
                    
                    create
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.3.2" data-path="../creation/empty.html">
            
                <a href="../creation/empty.html">
            
                    
                    empty
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.3.3" data-path="../creation/from.html">
            
                <a href="../creation/from.html">
            
                    
                    from
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.3.4" data-path="../creation/fromevent.html">
            
                <a href="../creation/fromevent.html">
            
                    
                    fromEvent
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.3.5" data-path="../creation/frompromise.html">
            
                <a href="../creation/frompromise.html">
            
                    
                    fromPromise
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.3.6" data-path="../creation/interval.html">
            
                <a href="../creation/interval.html">
            
                    
                    interval
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.3.7" data-path="../creation/of.html">
            
                <a href="../creation/of.html">
            
                    
                    of
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.3.8" data-path="../creation/range.html">
            
                <a href="../creation/range.html">
            
                    
                    range
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.3.9" data-path="../creation/throw.html">
            
                <a href="../creation/throw.html">
            
                    
                    throw
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.3.10" data-path="../creation/timer.html">
            
                <a href="../creation/timer.html">
            
                    
                    timer
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.2.4" data-path="../error_handling/">
            
                <a href="../error_handling/">
            
                    
                    错误处理
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.2.4.1" data-path="../error_handling/catch.html">
            
                <a href="../error_handling/catch.html">
            
                    
                    catchError
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.4.2" data-path="../error_handling/retry.html">
            
                <a href="../error_handling/retry.html">
            
                    
                    retry
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.4.3" data-path="../error_handling/retrywhen.html">
            
                <a href="../error_handling/retrywhen.html">
            
                    
                    retryWhen
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.2.5" data-path="../multicasting/">
            
                <a href="../multicasting/">
            
                    
                    多播
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.2.5.1" data-path="../multicasting/publish.html">
            
                <a href="../multicasting/publish.html">
            
                    
                    publish
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.5.2" data-path="../multicasting/multicast.html">
            
                <a href="../multicasting/multicast.html">
            
                    
                    multicast
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.5.3" data-path="../multicasting/share.html">
            
                <a href="../multicasting/share.html">
            
                    
                    share
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.5.4" data-path="../multicasting/sharereplay.html">
            
                <a href="../multicasting/sharereplay.html">
            
                    
                    shareReplay
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.2.6" data-path="../filtering/">
            
                <a href="../filtering/">
            
                    
                    过滤
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.2.6.1" data-path="../filtering/debounce.html">
            
                <a href="../filtering/debounce.html">
            
                    
                    debounce
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.6.2" data-path="../filtering/debouncetime.html">
            
                <a href="../filtering/debouncetime.html">
            
                    
                    debounceTime
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.6.3" data-path="../filtering/distinctuntilchanged.html">
            
                <a href="../filtering/distinctuntilchanged.html">
            
                    
                    distinctUntilChanged
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.6.4" data-path="../filtering/filter.html">
            
                <a href="../filtering/filter.html">
            
                    
                    filter
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.6.5" data-path="../filtering/first.html">
            
                <a href="../filtering/first.html">
            
                    
                    first
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.6.6" data-path="../filtering/ignoreelements.html">
            
                <a href="../filtering/ignoreelements.html">
            
                    
                    ignoreElements
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.6.7" data-path="../filtering/last.html">
            
                <a href="../filtering/last.html">
            
                    
                    last
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.6.8" data-path="../filtering/sample.html">
            
                <a href="../filtering/sample.html">
            
                    
                    sample
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.6.9" data-path="../filtering/single.html">
            
                <a href="../filtering/single.html">
            
                    
                    single
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.6.10" data-path="../filtering/skip.html">
            
                <a href="../filtering/skip.html">
            
                    
                    skip
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.6.11" data-path="../filtering/skipuntil.html">
            
                <a href="../filtering/skipuntil.html">
            
                    
                    skipUntil
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.6.12" data-path="../filtering/skipwhile.html">
            
                <a href="../filtering/skipwhile.html">
            
                    
                    skipWhile
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.6.13" data-path="../filtering/take.html">
            
                <a href="../filtering/take.html">
            
                    
                    take
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.6.14" data-path="../filtering/takeuntil.html">
            
                <a href="../filtering/takeuntil.html">
            
                    
                    takeUntil
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.6.15" data-path="../filtering/takewhile.html">
            
                <a href="../filtering/takewhile.html">
            
                    
                    takeWhile
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.6.16" data-path="../filtering/throttle.html">
            
                <a href="../filtering/throttle.html">
            
                    
                    throttle
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.6.17" data-path="../filtering/throttletime.html">
            
                <a href="../filtering/throttletime.html">
            
                    
                    throttleTime
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.2.7" data-path="../transformation/">
            
                <a href="../transformation/">
            
                    
                    转换
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.2.7.1" data-path="../transformation/buffer.html">
            
                <a href="../transformation/buffer.html">
            
                    
                    buffer
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.7.2" data-path="../transformation/buffercount.html">
            
                <a href="../transformation/buffercount.html">
            
                    
                    bufferCount
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.7.3" data-path="../transformation/buffertime.html">
            
                <a href="../transformation/buffertime.html">
            
                    
                    bufferTime
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.7.4" data-path="../transformation/buffertoggle.html">
            
                <a href="../transformation/buffertoggle.html">
            
                    
                    bufferToggle
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.7.5" data-path="../transformation/bufferwhen.html">
            
                <a href="../transformation/bufferwhen.html">
            
                    
                    bufferWhen
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.7.6" data-path="../transformation/concatmap.html">
            
                <a href="../transformation/concatmap.html">
            
                    
                    concatMap
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.7.7" data-path="../transformation/concatmapto.html">
            
                <a href="../transformation/concatmapto.html">
            
                    
                    concatMapTo
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.7.8" data-path="../transformation/exhaustmap.html">
            
                <a href="../transformation/exhaustmap.html">
            
                    
                    exhaustMap
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.7.9" data-path="../transformation/expand.html">
            
                <a href="../transformation/expand.html">
            
                    
                    expand
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.7.10" data-path="../transformation/exhaustmap.html">
            
                <a href="../transformation/exhaustmap.html">
            
                    
                    exhaustMap
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.7.11" data-path="../transformation/groupby.html">
            
                <a href="../transformation/groupby.html">
            
                    
                    groupBy
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.7.12" data-path="../transformation/map.html">
            
                <a href="../transformation/map.html">
            
                    
                    map
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.7.13" data-path="../transformation/mapto.html">
            
                <a href="../transformation/mapto.html">
            
                    
                    mapTo
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.7.14" data-path="../transformation/mergemap.html">
            
                <a href="../transformation/mergemap.html">
            
                    
                    mergeMap
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.7.15" data-path="../transformation/partition.html">
            
                <a href="../transformation/partition.html">
            
                    
                    partition
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.7.16" data-path="../transformation/pluck.html">
            
                <a href="../transformation/pluck.html">
            
                    
                    pluck
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.7.17" data-path="../transformation/reduce.html">
            
                <a href="../transformation/reduce.html">
            
                    
                    reduce
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.7.18" data-path="../transformation/scan.html">
            
                <a href="../transformation/scan.html">
            
                    
                    scan
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.7.19" data-path="../transformation/switchmap.html">
            
                <a href="../transformation/switchmap.html">
            
                    
                    switchMap
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.7.20" data-path="../transformation/window.html">
            
                <a href="../transformation/window.html">
            
                    
                    window
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.7.21" data-path="../transformation/windowcount.html">
            
                <a href="../transformation/windowcount.html">
            
                    
                    windowCount
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.7.22" data-path="../transformation/windowtime.html">
            
                <a href="../transformation/windowtime.html">
            
                    
                    windowTime
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.7.23" data-path="../transformation/windowtoggle.html">
            
                <a href="../transformation/windowtoggle.html">
            
                    
                    windowToggle
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.7.24" data-path="../transformation/windowwhen.html">
            
                <a href="../transformation/windowwhen.html">
            
                    
                    windowWhen
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.2.8" data-path="../utility/">
            
                <a href="../utility/">
            
                    
                    工具
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.2.8.1" data-path="../utility/do.html">
            
                <a href="../utility/do.html">
            
                    
                    do
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.8.2" data-path="../utility/delay.html">
            
                <a href="../utility/delay.html">
            
                    
                    delay
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.8.3" data-path="../utility/delaywhen.html">
            
                <a href="../utility/delaywhen.html">
            
                    
                    delayWhen
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.8.4" data-path="../utility/dematerialize.html">
            
                <a href="../utility/dematerialize.html">
            
                    
                    dematerialize
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.8.5" data-path="../utility/let.html">
            
                <a href="../utility/let.html">
            
                    
                    let
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.8.6" data-path="../utility/timeout.html">
            
                <a href="../utility/timeout.html">
            
                    
                    timeout
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2.8.7" data-path="../utility/topromise.html">
            
                <a href="../utility/topromise.html">
            
                    
                    toPromise
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.2.9" data-path="../complete.html">
            
                <a href="../complete.html">
            
                    
                    完整列表
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="../../recipes/">
            
                <a href="../../recipes/">
            
                    
                    食谱
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.3.1" data-path="../../recipes/smartcounter.html">
            
                <a href="../../recipes/smartcounter.html">
            
                    
                    智能计数器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.2" data-path="../../recipes/progressbar.html">
            
                <a href="../../recipes/progressbar.html">
            
                    
                    进度条
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3.3" data-path="../../recipes/gameloop.html">
            
                <a href="../../recipes/gameloop.html">
            
                    
                    游戏循环
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="../../concepts/">
            
                <a href="../../concepts/">
            
                    
                    概念
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.4.1" data-path="../../concepts/rxjs5-6.html">
            
                <a href="../../concepts/rxjs5-6.html">
            
                    
                    RxJS v5 -> v6 升级
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.4.2" data-path="../../concepts/operator-imports.html">
            
                <a href="../../concepts/operator-imports.html">
            
                    
                    理解操作符导入
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >forkJoin</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="forkjoin">forkJoin</h1>
<h4 id="&#x51FD;&#x6570;&#x7B7E;&#x540D;-forkjoinargs-selector--function-observable">&#x51FD;&#x6570;&#x7B7E;&#x540D;: <code>forkJoin(...args, selector : function): Observable</code></h4>
<h2 id="&#x5F53;&#x6240;&#x6709;-observables-&#x5B8C;&#x6210;&#x65F6;&#xFF0C;&#x53D1;&#x51FA;&#x6BCF;&#x4E2A;-observable-&#x7684;&#x6700;&#x65B0;&#x503C;&#x3002;">&#x5F53;&#x6240;&#x6709; observables &#x5B8C;&#x6210;&#x65F6;&#xFF0C;&#x53D1;&#x51FA;&#x6BCF;&#x4E2A; observable &#x7684;&#x6700;&#x65B0;&#x503C;&#x3002;</h2>
<hr>
<p><img align="absmiddle" alt=":bulb:" class="emoji" src="../../gitbook/gitbook-plugin-advanced-emoji/emojis/bulb.png" title=":bulb:">  &#x5982;&#x679C;&#x4F60;&#x60F3;&#x8981;&#x591A;&#x4E2A; observables &#x6309;&#x53D1;&#x51FA;&#x987A;&#x5E8F;&#x76F8;&#x5BF9;&#x5E94;&#x7684;&#x503C;&#x7684;&#x7EC4;&#x5408;&#xFF0C;&#x8BD5;&#x8BD5; <a href="zip.html">zip</a>&#xFF01;</p>
<p><img align="absmiddle" alt=":warning:" class="emoji" src="../../gitbook/gitbook-plugin-advanced-emoji/emojis/warning.png" title=":warning:"> &#x5982;&#x679C;&#x5185;&#x90E8; observable &#x4E0D;&#x5B8C;&#x6210;&#x7684;&#x8BDD;&#xFF0C;<code>forkJoin</code> &#x6C38;&#x8FDC;&#x4E0D;&#x4F1A;&#x53D1;&#x51FA;&#x503C;&#xFF01;</p>
<hr>
<h3 id="&#x4E3A;&#x4EC0;&#x4E48;&#x4F7F;&#x7528;-forkjoin&#xFF1F;">&#x4E3A;&#x4EC0;&#x4E48;&#x4F7F;&#x7528; <code>forkJoin</code>&#xFF1F;</h3>
<p>&#x5F53;&#x6709;&#x4E00;&#x7EC4; observables&#xFF0C;&#x4F46;&#x4F60;&#x53EA;&#x5173;&#x5FC3;&#x6BCF;&#x4E2A; observable &#x6700;&#x540E;&#x53D1;&#x51FA;&#x7684;&#x503C;&#x65F6;&#xFF0C;&#x6B64;&#x64CD;&#x4F5C;&#x7B26;&#x662F;&#x6700;&#x9002;&#x5408;&#x7684;&#x3002;&#x6B64;&#x64CD;&#x4F5C;&#x7B26;&#x7684;&#x4E00;&#x4E2A;&#x5E38;&#x89C1;&#x7528;&#x4F8B;&#x662F;&#x5728;&#x9875;&#x9762;&#x52A0;&#x8F7D;(&#x6216;&#x5176;&#x4ED6;&#x4E8B;&#x4EF6;)&#x65F6;&#x4F60;&#x5E0C;&#x671B;&#x53D1;&#x8D77;&#x591A;&#x4E2A;&#x8BF7;&#x6C42;&#xFF0C;&#x5E76;&#x5728;&#x6240;&#x6709;&#x8BF7;&#x6C42;&#x90FD;&#x54CD;&#x5E94;&#x540E;&#x518D;&#x91C7;&#x53D6;&#x884C;&#x52A8;&#x3002;&#x5B83;&#x53EF;&#x80FD;&#x4E0E; <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all" target="_blank"><code>Promise.all</code></a> &#x7684;&#x4F7F;&#x7528;&#x65B9;&#x5F0F;&#x7C7B;&#x4F3C;&#x3002;</p>
<p>&#x6CE8;&#x610F;&#xFF0C;&#x5982;&#x679C;&#x4EFB;&#x610F;&#x4F5C;&#x7528;&#x4E8E; <code>forkJoin</code> &#x7684;&#x5185;&#x90E8; observable &#x62A5;&#x9519;&#x7684;&#x8BDD;&#xFF0C;&#x5BF9;&#x4E8E;&#x90A3;&#x4E9B;&#x5728;&#x5185;&#x90E8; observable &#x4E0A;&#x6CA1;&#x6709;&#x6B63;&#x786E; <a href="../error_handling/catch.html"><code>catch</code></a> &#x9519;&#x8BEF;&#xFF0C;&#x4ECE;&#x800C;&#x5BFC;&#x81F4;&#x5B8C;&#x6210;&#x7684; observable&#xFF0C;&#x4F60;&#x5C06;&#x4E22;&#x5931;&#x5B83;&#x4EEC;&#x7684;&#x503C; (&#x53C2;&#x89C1;&#x793A;&#x4F8B; 4)&#x3002;&#x5982;&#x679C;&#x4F60;&#x53EA;&#x5173;&#x5FC3;&#x6240;&#x6709;&#x5185;&#x90E8; observables &#x662F;&#x5426;&#x6210;&#x529F;&#x5B8C;&#x6210;&#x7684;&#x8BDD;&#xFF0C;&#x53EF;&#x4EE5;<a href="#%E5%9C%A8%E5%A4%96%E9%83%A8%E5%A4%84%E7%90%86%E9%94%99%E8%AF%AF">&#x5728;&#x5916;&#x90E8;&#x6355;&#x83B7;&#x9519;&#x8BEF;</a>&#x3002;</p>
<p>&#x8FD8;&#x9700;&#x8981;&#x6CE8;&#x610F;&#x7684;&#x662F;&#x5982;&#x679C; observable &#x53D1;&#x51FA;&#x7684;&#x9879;&#x591A;&#x4E8E;&#x4E00;&#x4E2A;&#x7684;&#x8BDD;&#xFF0C;&#x5E76;&#x4E14;&#x4F60;&#x53EA;&#x5173;&#x5FC3;&#x524D;&#x4E00;&#x4E2A;&#x53D1;&#x51FA;&#x7684;&#x8BDD;&#xFF0C;&#x90A3;&#x4E48; <code>forkJoin</code> &#x5E76;&#x975E;&#x6B63;&#x786E;&#x7684;&#x9009;&#x62E9;&#x3002;&#x5728;&#x8FD9;&#x79CD;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x5E94;&#x8BE5;&#x9009;&#x62E9;&#x50CF; <a href="combinelatest.html">combineLatest</a> &#x6216; <a href="zip.html">zip</a> &#x8FD9;&#x6837;&#x7684;&#x64CD;&#x4F5C;&#x7B26;&#x3002;</p>
<div class="ua-ad"><a href="https://ultimateangular.com/?ref=76683_kee7y7vk" target="_blank"><img src="https://ultimateangular.com/assets/img/banners/ua-leader.svg"></a></div>

<h3 id="&#x793A;&#x4F8B;">&#x793A;&#x4F8B;</h3>
<h5 id="&#x793A;&#x4F8B;-1-observables-&#x518D;&#x4E0D;&#x540C;&#x7684;&#x65F6;&#x95F4;&#x95F4;&#x9694;&#x540E;&#x5B8C;&#x6210;">&#x793A;&#x4F8B; 1: Observables &#x518D;&#x4E0D;&#x540C;&#x7684;&#x65F6;&#x95F4;&#x95F4;&#x9694;&#x540E;&#x5B8C;&#x6210;</h5>
<p>(
<a href="https://stackblitz.com/edit/typescript-bqxg9x?file=index.ts&amp;devtoolsheight=100" target="_blank">StackBlitz</a>
| <a href="http://jsbin.com/remiduhimu/1/edit?js,console" target="_blank">jsBin</a> |
<a href="https://jsfiddle.net/btroncone/5fj77920/81/" target="_blank">jsFiddle</a> )</p>
<pre class="language-"><code class="lang-js"><span class="token comment">// RxJS v6+</span>
<span class="token keyword">import</span> <span class="token punctuation">{</span> delay<span class="token punctuation">,</span> take <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">&apos;rxjs/operators&apos;</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token punctuation">{</span> forkJoin<span class="token punctuation">,</span> <span class="token keyword">of</span><span class="token punctuation">,</span> interval <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">&apos;rxjs&apos;</span><span class="token punctuation">;</span>

<span class="token keyword">const</span> <span class="token function-variable function">myPromise</span> <span class="token operator">=</span> val <span class="token operator">=&gt;</span>
  <span class="token keyword">new</span> <span class="token class-name">Promise</span><span class="token punctuation">(</span>resolve <span class="token operator">=&gt;</span>
    <span class="token function">setTimeout</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token function">resolve</span><span class="token punctuation">(</span><span class="token template-string"><span class="token string">`Promise Resolved: </span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>val<span class="token interpolation-punctuation punctuation">}</span></span><span class="token string">`</span></span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">5000</span><span class="token punctuation">)</span>
  <span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token comment">/*
  &#x5F53;&#x6240;&#x6709; observables &#x5B8C;&#x6210;&#x65F6;&#xFF0C;&#x5C06;&#x6BCF;&#x4E2A; observable 
  &#x7684;&#x6700;&#x65B0;&#x503C;&#x4F5C;&#x4E3A;&#x6570;&#x7EC4;&#x53D1;&#x51FA;
*/</span>
<span class="token keyword">const</span> example <span class="token operator">=</span> <span class="token function">forkJoin</span><span class="token punctuation">(</span>
  <span class="token comment">// &#x7ACB;&#x5373;&#x53D1;&#x51FA; &apos;Hello&apos;</span>
  <span class="token keyword">of</span><span class="token punctuation">(</span><span class="token string">&apos;Hello&apos;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
  <span class="token comment">// 1&#x79D2;&#x540E;&#x53D1;&#x51FA; &apos;World&apos;</span>
  <span class="token keyword">of</span><span class="token punctuation">(</span><span class="token string">&apos;World&apos;</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">pipe</span><span class="token punctuation">(</span><span class="token function">delay</span><span class="token punctuation">(</span><span class="token number">1000</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
  <span class="token comment">// 1&#x79D2;&#x540E;&#x53D1;&#x51FA;0</span>
  <span class="token function">interval</span><span class="token punctuation">(</span><span class="token number">1000</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">pipe</span><span class="token punctuation">(</span><span class="token function">take</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
  <span class="token comment">// &#x4EE5;1&#x79D2;&#x7684;&#x65F6;&#x95F4;&#x95F4;&#x9694;&#x53D1;&#x51FA;0&#x548C;1</span>
  <span class="token function">interval</span><span class="token punctuation">(</span><span class="token number">1000</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">pipe</span><span class="token punctuation">(</span><span class="token function">take</span><span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
  <span class="token comment">// 5&#x79D2;&#x540E;&#x89E3;&#x6790; &apos;Promise Resolved&apos; &#x7684; promise</span>
  <span class="token function">myPromise</span><span class="token punctuation">(</span><span class="token string">&apos;RESULT&apos;</span><span class="token punctuation">)</span>
<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">//&#x8F93;&#x51FA;: [&quot;Hello&quot;, &quot;World&quot;, 0, 1, &quot;Promise Resolved: RESULT&quot;]</span>
<span class="token keyword">const</span> subscribe <span class="token operator">=</span> example<span class="token punctuation">.</span><span class="token function">subscribe</span><span class="token punctuation">(</span>val <span class="token operator">=&gt;</span> console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>val<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
<h5 id="&#x793A;&#x4F8B;-2-&#x53D1;&#x8D77;&#x4EFB;&#x610F;&#x591A;&#x4E2A;&#x8BF7;&#x6C42;">&#x793A;&#x4F8B; 2: &#x53D1;&#x8D77;&#x4EFB;&#x610F;&#x591A;&#x4E2A;&#x8BF7;&#x6C42;</h5>
<p>(
<a href="https://stackblitz.com/edit/typescript-3mbbjw?file=index.ts&amp;devtoolsheight=100" target="_blank">StackBlitz</a>
| <a href="http://jsbin.com/febejakapi/1/edit?js,console" target="_blank">jsBin</a> |
<a href="https://jsfiddle.net/btroncone/0b8Lnh7s/1/" target="_blank">jsFiddle</a> )</p>
<pre class="language-"><code class="lang-js"><span class="token comment">// RxJS v6+</span>
<span class="token keyword">import</span> <span class="token punctuation">{</span> mergeMap <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">&apos;rxjs/operators&apos;</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token punctuation">{</span> forkJoin<span class="token punctuation">,</span> <span class="token keyword">of</span> <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">&apos;rxjs&apos;</span><span class="token punctuation">;</span>

<span class="token keyword">const</span> <span class="token function-variable function">myPromise</span> <span class="token operator">=</span> val <span class="token operator">=&gt;</span>
  <span class="token keyword">new</span> <span class="token class-name">Promise</span><span class="token punctuation">(</span>resolve <span class="token operator">=&gt;</span>
    <span class="token function">setTimeout</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token function">resolve</span><span class="token punctuation">(</span><span class="token template-string"><span class="token string">`Promise Resolved: </span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>val<span class="token interpolation-punctuation punctuation">}</span></span><span class="token string">`</span></span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">5000</span><span class="token punctuation">)</span>
  <span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token keyword">const</span> source <span class="token operator">=</span> <span class="token keyword">of</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">,</span> <span class="token number">4</span><span class="token punctuation">,</span> <span class="token number">5</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// &#x53D1;&#x51FA;&#x6570;&#x7EC4;&#x7684;&#x5168;&#x90E8;5&#x4E2A;&#x7ED3;&#x679C;</span>
<span class="token keyword">const</span> example <span class="token operator">=</span> source<span class="token punctuation">.</span><span class="token function">pipe</span><span class="token punctuation">(</span><span class="token function">mergeMap</span><span class="token punctuation">(</span>q <span class="token operator">=&gt;</span> <span class="token function">forkJoin</span><span class="token punctuation">(</span><span class="token operator">...</span>q<span class="token punctuation">.</span><span class="token function">map</span><span class="token punctuation">(</span>myPromise<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">/*
  &#x8F93;&#x51FA;:
  [
   &quot;Promise Resolved: 1&quot;,
   &quot;Promise Resolved: 2&quot;,
   &quot;Promise Resolved: 3&quot;,
   &quot;Promise Resolved: 4&quot;,
   &quot;Promise Resolved: 5&quot;
  ]
*/</span>
<span class="token keyword">const</span> subscribe <span class="token operator">=</span> example<span class="token punctuation">.</span><span class="token function">subscribe</span><span class="token punctuation">(</span>val <span class="token operator">=&gt;</span> console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>val<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
<h5 id="&#x793A;&#x4F8B;-3-&#x5728;&#x5916;&#x90E8;&#x5904;&#x7406;&#x9519;&#x8BEF;">&#x793A;&#x4F8B; 3: &#x5728;&#x5916;&#x90E8;&#x5904;&#x7406;&#x9519;&#x8BEF;</h5>
<p>(
<a href="https://stackblitz.com/edit/typescript-xgskpm?file=index.ts&amp;devtoolsheight=100" target="_blank">StackBlitz</a>
| <a href="http://jsbin.com/gugawucixi/1/edit?js,console" target="_blank">jsBin</a> |
<a href="https://jsfiddle.net/btroncone/6vz7tjx2/1/" target="_blank">jsFiddle</a> )</p>
<pre class="language-"><code class="lang-js"><span class="token comment">// RxJS v6+</span>
<span class="token keyword">import</span> <span class="token punctuation">{</span> delay<span class="token punctuation">,</span> catchError <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">&apos;rxjs/operators&apos;</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token punctuation">{</span> forkJoin<span class="token punctuation">,</span> <span class="token keyword">of</span><span class="token punctuation">,</span> throwError <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">&apos;rxjs&apos;</span><span class="token punctuation">;</span>

<span class="token comment">/*
  &#x5F53;&#x6240;&#x6709; observables &#x5B8C;&#x6210;&#x65F6;&#xFF0C;&#x5C06;&#x6BCF;&#x4E2A; observable 
  &#x7684;&#x6700;&#x65B0;&#x503C;&#x4F5C;&#x4E3A;&#x6570;&#x7EC4;&#x53D1;&#x51FA;
*/</span>
<span class="token keyword">const</span> example <span class="token operator">=</span> <span class="token function">forkJoin</span><span class="token punctuation">(</span>
  <span class="token comment">// &#x7ACB;&#x5373;&#x53D1;&#x51FA; &apos;Hello&apos;</span>
  <span class="token keyword">of</span><span class="token punctuation">(</span><span class="token string">&apos;Hello&apos;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
  <span class="token comment">// 1&#x79D2;&#x540E;&#x53D1;&#x51FA; &apos;World&apos;</span>
  <span class="token keyword">of</span><span class="token punctuation">(</span><span class="token string">&apos;World&apos;</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">pipe</span><span class="token punctuation">(</span><span class="token function">delay</span><span class="token punctuation">(</span><span class="token number">1000</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
  <span class="token comment">// &#x629B;&#x51FA;&#x9519;&#x8BEF;</span>
  <span class="token function">_throw</span><span class="token punctuation">(</span><span class="token string">&apos;This will error&apos;</span><span class="token punctuation">)</span>
<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">pipe</span><span class="token punctuation">(</span><span class="token function">catchError</span><span class="token punctuation">(</span>error <span class="token operator">=&gt;</span> <span class="token keyword">of</span><span class="token punctuation">(</span>error<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// &#x8F93;&#x51FA;: &apos;This will Error&apos;</span>
<span class="token keyword">const</span> subscribe <span class="token operator">=</span> example<span class="token punctuation">.</span><span class="token function">subscribe</span><span class="token punctuation">(</span>val <span class="token operator">=&gt;</span> console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>val<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
<h5 id="&#x793A;&#x4F8B;-4-&#x5F53;&#x67D0;&#x4E2A;&#x5185;&#x90E8;-observable-&#x62A5;&#x9519;&#x65F6;&#x5F97;&#x5230;&#x6210;&#x529F;&#x7ED3;&#x679C;">&#x793A;&#x4F8B; 4: &#x5F53;&#x67D0;&#x4E2A;&#x5185;&#x90E8; observable &#x62A5;&#x9519;&#x65F6;&#x5F97;&#x5230;&#x6210;&#x529F;&#x7ED3;&#x679C;</h5>
<p>(
<a href="https://stackblitz.com/edit/typescript-hydgiu?file=index.ts&amp;devtoolsheight=100" target="_blank">StackBlitz</a>
| <a href="http://jsbin.com/memajepefe/1/edit?js,console" target="_blank">jsBin</a> |
<a href="https://jsfiddle.net/btroncone/emdu4doy/1/" target="_blank">jsFiddle</a> )</p>
<pre class="language-"><code class="lang-js"><span class="token comment">// RxJS v6+</span>
<span class="token keyword">import</span> <span class="token punctuation">{</span> delay<span class="token punctuation">,</span> catchError <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">&apos;rxjs/operators&apos;</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token punctuation">{</span> forkJoin<span class="token punctuation">,</span> <span class="token keyword">of</span><span class="token punctuation">,</span> throwError <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">&apos;rxjs&apos;</span><span class="token punctuation">;</span>

<span class="token comment">/*
  &#x5F53;&#x6240;&#x6709; observables &#x5B8C;&#x6210;&#x65F6;&#xFF0C;&#x5C06;&#x6BCF;&#x4E2A; observable 
  &#x7684;&#x6700;&#x65B0;&#x503C;&#x4F5C;&#x4E3A;&#x6570;&#x7EC4;&#x53D1;&#x51FA;
*/</span>
<span class="token keyword">const</span> example <span class="token operator">=</span> <span class="token function">forkJoin</span><span class="token punctuation">(</span>
  <span class="token comment">// &#x7ACB;&#x5373;&#x53D1;&#x51FA; &apos;Hello&apos;</span>
  <span class="token keyword">of</span><span class="token punctuation">(</span><span class="token string">&apos;Hello&apos;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
  <span class="token comment">// 1&#x79D2;&#x540E;&#x53D1;&#x51FA; &apos;World&apos;</span>
  <span class="token keyword">of</span><span class="token punctuation">(</span><span class="token string">&apos;World&apos;</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">pipe</span><span class="token punctuation">(</span><span class="token function">delay</span><span class="token punctuation">(</span><span class="token number">1000</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
  <span class="token comment">// &#x629B;&#x51FA;&#x9519;&#x8BEF;</span>
  <span class="token function">_throw</span><span class="token punctuation">(</span><span class="token string">&apos;This will error&apos;</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">pipe</span><span class="token punctuation">(</span><span class="token function">catchError</span><span class="token punctuation">(</span>error <span class="token operator">=&gt;</span> <span class="token keyword">of</span><span class="token punctuation">(</span>error<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment">// &#x8F93;&#x51FA;: [&quot;Hello&quot;, &quot;World&quot;, &quot;This will error&quot;]</span>
<span class="token keyword">const</span> subscribe <span class="token operator">=</span> example<span class="token punctuation">.</span><span class="token function">subscribe</span><span class="token punctuation">(</span>val <span class="token operator">=&gt;</span> console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>val<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
<h5 id="&#x793A;&#x4F8B;-5-angular-&#x4E2D;&#x7684;-forkjoin">&#x793A;&#x4F8B; 5: Angular &#x4E2D;&#x7684; forkJoin</h5>
<p>( <a href="https://plnkr.co/edit/ElTrOg8NfR3WbbAfjBXQ?p=preview" target="_blank">plunker</a> )</p>
<pre class="language-"><code class="lang-js">@<span class="token function">Injectable</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token keyword">export</span> <span class="token keyword">class</span> <span class="token class-name">MyService</span> <span class="token punctuation">{</span>
  <span class="token function">makeRequest</span><span class="token punctuation">(</span>value<span class="token punctuation">:</span> string<span class="token punctuation">,</span> delayDuration<span class="token punctuation">:</span> number<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token comment">// &#x6A21;&#x62DF; http &#x8BF7;&#x6C42;</span>
    <span class="token keyword">return</span> <span class="token keyword">of</span><span class="token punctuation">(</span><span class="token template-string"><span class="token string">`Complete: </span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>value<span class="token interpolation-punctuation punctuation">}</span></span><span class="token string">`</span></span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">pipe</span><span class="token punctuation">(</span>
      <span class="token function">delay</span><span class="token punctuation">(</span>delayDuration<span class="token punctuation">)</span>
    <span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

@<span class="token function">Component</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
  selector<span class="token punctuation">:</span> <span class="token string">&apos;my-app&apos;</span><span class="token punctuation">,</span>
  template<span class="token punctuation">:</span> <span class="token template-string"><span class="token string">`
    &lt;div&gt;
      &lt;h2&gt;forkJoin Example&lt;/h2&gt;
      &lt;ul&gt;
        &lt;li&gt; {{propOne}} &lt;/li&gt;
        &lt;li&gt; {{propTwo}} &lt;/li&gt;
        &lt;li&gt; {{propThree}} &lt;/li&gt;
      &lt;/ul&gt;
    &lt;/div&gt;
  `</span></span><span class="token punctuation">,</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span>
<span class="token keyword">export</span> <span class="token keyword">class</span> <span class="token class-name">App</span> <span class="token punctuation">{</span>
  <span class="token keyword">public</span> propOne<span class="token punctuation">:</span> string<span class="token punctuation">;</span>
  <span class="token keyword">public</span> propTwo<span class="token punctuation">:</span> string<span class="token punctuation">;</span>
  <span class="token keyword">public</span> propThree<span class="token punctuation">:</span> string<span class="token punctuation">;</span>
  <span class="token function">constructor</span><span class="token punctuation">(</span><span class="token keyword">private</span> _myService<span class="token punctuation">:</span> MyService<span class="token punctuation">)</span> <span class="token punctuation">{</span><span class="token punctuation">}</span>

  <span class="token function">ngOnInit</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token comment">// &#x4F7F;&#x7528;&#x4E0D;&#x540C;&#x7684;&#x5EF6;&#x8FDF;&#x6A21;&#x62DF;3&#x4E2A;&#x8BF7;&#x6C42;</span>
    <span class="token function">forkJoin</span><span class="token punctuation">(</span>
      <span class="token keyword">this</span><span class="token punctuation">.</span>_myService<span class="token punctuation">.</span><span class="token function">makeRequest</span><span class="token punctuation">(</span><span class="token string">&apos;Request One&apos;</span><span class="token punctuation">,</span> <span class="token number">2000</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
      <span class="token keyword">this</span><span class="token punctuation">.</span>_myService<span class="token punctuation">.</span><span class="token function">makeRequest</span><span class="token punctuation">(</span><span class="token string">&apos;Request Two&apos;</span><span class="token punctuation">,</span> <span class="token number">1000</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
      <span class="token keyword">this</span><span class="token punctuation">.</span>_myService<span class="token punctuation">.</span><span class="token function">makeRequest</span><span class="token punctuation">(</span><span class="token string">&apos;Request Three&apos;</span><span class="token punctuation">,</span> <span class="token number">3000</span><span class="token punctuation">)</span>
    <span class="token punctuation">)</span>
    <span class="token punctuation">.</span><span class="token function">subscribe</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">[</span>res1<span class="token punctuation">,</span> res2<span class="token punctuation">,</span> res3<span class="token punctuation">]</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
      <span class="token keyword">this</span><span class="token punctuation">.</span>propOne <span class="token operator">=</span> res1<span class="token punctuation">;</span>
      <span class="token keyword">this</span><span class="token punctuation">.</span>propTwo <span class="token operator">=</span> res2<span class="token punctuation">;</span>
      <span class="token keyword">this</span><span class="token punctuation">.</span>propThree <span class="token operator">=</span> res3<span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<h3 id="&#x5176;&#x4ED6;&#x8D44;&#x6E90;">&#x5176;&#x4ED6;&#x8D44;&#x6E90;</h3>
<ul>
<li><a href="https://cn.rx.js.org/class/es6/Observable.js~Observable.html#static-method-forkJoin" target="_blank">forkJoin</a> <img align="absmiddle" alt=":newspaper:" class="emoji" src="../../gitbook/gitbook-plugin-advanced-emoji/emojis/newspaper.png" title=":newspaper:"> - &#x5B98;&#x65B9;&#x6587;&#x6863;</li>
</ul>
<hr>
<blockquote>
<p><img align="absmiddle" alt=":file_folder:" class="emoji" src="../../gitbook/gitbook-plugin-advanced-emoji/emojis/file_folder.png" title=":file_folder:"> &#x6E90;&#x7801;:  <a href="https://github.com/ReactiveX/rxjs/blob/master/src/observable/ForkJoinObservable.ts" target="_blank">https://github.com/ReactiveX/rxjs/blob/master/src/observable/ForkJoinObservable.ts</a></p>
</blockquote>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="concatall.html" class="navigation navigation-prev " aria-label="Previous page: concatAll">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="merge.html" class="navigation navigation-next " aria-label="Next page: merge">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"forkJoin","level":"2.2.1.5","depth":3,"next":{"title":"merge","level":"2.2.1.6","depth":3,"path":"operators/combination/merge.md","ref":"operators/combination/merge.md","articles":[]},"previous":{"title":"concatAll","level":"2.2.1.4","depth":3,"path":"operators/combination/concatall.md","ref":"operators/combination/concatall.md","articles":[]},"dir":"ltr"},"config":{"plugins":["include-codeblock","advanced-emoji","prism","highlight","copy-code-button","edit-link","github","github-buttons"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"prism":{},"github":{"url":"https://github.com/RxJS-CN/learn-rxjs-operators"},"search":{},"lunr":{"maxIndexSize":1000000},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"github-buttons":{"buttons":[{"user":"RxJS-CN","repo":"learn-rxjs-operators","type":"star","size":"small","count":true},{"user":"RxJS-CN","repo":"learn-rxjs-operators","type":"fork","size":"small","count":true}]},"copy-code-button":{},"advanced-emoji":{"embedEmojis":false},"include-codeblock":{"check":false,"edit":false,"fixlang":false,"lang":"","template":"default","theme":"chrome","unindent":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"edit-link":{"label":"帮忙纠错","base":"https://github.com/RxJS-CN/learn-rxjs-operators/tree/master"},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"index.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"学习 RxJS 操作符","gitbook":"3.1.1"},"file":{"path":"operators/combination/forkjoin.md","mtime":"2018-10-15T09:07:06.000Z","type":"markdown"},"gitbook":{"version":"3.1.1","time":"2018-10-15T09:31:22.754Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-copy-code-button/toggle.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-edit-link/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-github/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-github-buttons/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

